home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / asa / asa_user.h < prev    next >
C/C++ Source or Header  |  1994-10-23  |  5KB  |  247 lines

  1.  /* $Id: asa_user.h,v 4.2 1994/10/23 23:35:20 ingber Exp ingber $ */
  2.  
  3.  /* asa_user.h for Adaptive Simulated Annealing */
  4.  
  5. #include <errno.h>
  6. #include <math.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>        /* misc defs on most machines */
  9. #include <string.h>
  10.  
  11. /* test for memory leaks */
  12. /* #include "leak.h" */
  13.  
  14. #define    TRUE            1
  15. #define    FALSE            0
  16.  
  17.  /* DEFAULT PARAMETERS SETTINGS */
  18.  
  19.  /* Pre-Compile Options */
  20.  
  21. #ifndef OPTIONS_FILE
  22. #define OPTIONS_FILE FALSE
  23. #endif
  24.  
  25. #ifndef ASA_LIB
  26. #define ASA_LIB FALSE
  27. #endif
  28.  
  29. #ifndef HAVE_ANSI
  30. #define HAVE_ANSI TRUE
  31. #endif
  32.  
  33. #ifndef IO_PROTOTYPES
  34. #define IO_PROTOTYPES TRUE
  35. #endif
  36.  
  37. #ifndef TIME_CALC
  38. #define TIME_CALC FALSE
  39. #endif
  40.  
  41. #ifndef INT_LONG
  42. #define INT_LONG TRUE
  43. #endif
  44.  
  45. #if INT_LONG
  46. #define LONG_INT long int
  47. #else
  48. #define LONG_INT int
  49. #endif
  50.  
  51. #ifndef INT_ALLOC
  52. #define INT_ALLOC FALSE
  53. #endif
  54.  
  55. #if INT_ALLOC
  56. #define ALLOC_INT int
  57. #else
  58. #define ALLOC_INT LONG_INT
  59. #endif
  60.  
  61.  /* You can define SMALL_FLOAT to better correlate to your machine's
  62.     precision, i.e., as used in asa */
  63. #ifndef SMALL_FLOAT
  64. #define SMALL_FLOAT 1.0E-18
  65. #endif
  66.  
  67.  /* You can define your machine's maximum and minimum doubles here */
  68. #ifndef MIN_DOUBLE
  69. #define MIN_DOUBLE SMALL_FLOAT
  70. #endif
  71.  
  72. #ifndef MAX_DOUBLE
  73. #define MAX_DOUBLE (1.0/SMALL_FLOAT)
  74. #endif
  75.  
  76. #ifndef EPS_DOUBLE
  77. #define EPS_DOUBLE SMALL_FLOAT
  78. #endif
  79.  
  80. #ifndef ASA_TEST
  81. #define ASA_TEST FALSE
  82. #endif
  83.  
  84. #ifndef ASA_TEMPLATE
  85. #define ASA_TEMPLATE FALSE
  86. #endif
  87.  
  88. #ifndef OPTIONAL_DATA
  89. #define OPTIONAL_DATA FALSE
  90. #endif
  91.  
  92. #ifndef USER_REANNEAL_FUNCTION
  93. #define USER_REANNEAL_FUNCTION FALSE
  94. #endif
  95.  
  96. #ifndef USER_COST_SCHEDULE
  97. #define USER_COST_SCHEDULE FALSE
  98. #endif
  99.  
  100. #define INTEGER_TYPE        ((int) 1)
  101. #define REAL_TYPE        ((int) -1)
  102. #define INTEGER_NO_REANNEAL    ((int) 2)
  103. #define REAL_NO_REANNEAL    ((int) -2)
  104.  
  105.  /* Set this to TRUE to self-optimize the Program Options */
  106. #ifndef SELF_OPTIMIZE
  107. #define SELF_OPTIMIZE FALSE
  108. #endif
  109.  
  110. #ifndef USER_ASA_OUT
  111. #define USER_ASA_OUT FALSE
  112. #endif
  113.  
  114. #ifndef ASA_SAMPLE
  115. #define ASA_SAMPLE FALSE
  116. #endif
  117.  
  118. #ifndef ASA_PARALLEL
  119. #define ASA_PARALLEL FALSE
  120. #endif
  121.  
  122. #ifndef __GNUC__        /* this can be useful when using gcc */
  123. #define __GNUC__ FALSE
  124. #endif
  125.  
  126.  /* Program Options */
  127.  
  128. typedef struct
  129.   {
  130.     LONG_INT LIMIT_ACCEPTANCES;
  131.     LONG_INT LIMIT_GENERATED;
  132.     int LIMIT_INVALID_GENERATED_STATES;
  133.     double ACCEPTED_TO_GENERATED_RATIO;
  134.  
  135.     double COST_PRECISION;
  136.     int MAXIMUM_COST_REPEAT;
  137.     int NUMBER_COST_SAMPLES;
  138.     double TEMPERATURE_RATIO_SCALE;
  139.     double COST_PARAMETER_SCALE;
  140.     double TEMPERATURE_ANNEAL_SCALE;
  141.     int USER_INITIAL_COST_TEMP;
  142.     double *user_cost_temperature;
  143.  
  144.     int INCLUDE_INTEGER_PARAMETERS;
  145.     int USER_INITIAL_PARAMETERS;
  146.     ALLOC_INT SEQUENTIAL_PARAMETERS;
  147.     double INITIAL_PARAMETER_TEMPERATURE;
  148.     int RATIO_TEMPERATURE_SCALES;
  149.     double *user_temperature_ratio;
  150.     int USER_INITIAL_PARAMETERS_TEMPS;
  151.     double *user_parameter_temperature;
  152.  
  153.     int TESTING_FREQUENCY_MODULUS;
  154.     int ACTIVATE_REANNEAL;
  155.     double REANNEAL_RESCALE;
  156.     LONG_INT MAXIMUM_REANNEAL_INDEX;
  157.  
  158.     double DELTA_X;
  159.     int DELTA_PARAMETERS;
  160.     double *user_delta_parameter;
  161.     int USER_TANGENTS;
  162.     int CURVATURE_0;
  163.  
  164.     int QUENCH_PARAMETERS;
  165.     double *user_quench_param_scale;
  166.     int QUENCH_COST;
  167.     double *user_quench_cost_scale;
  168.  
  169. #if OPTIONAL_DATA
  170.     double *asa_data;
  171. #endif
  172. #if USER_ASA_OUT
  173.     char *asa_out_file;
  174. #endif
  175. #if USER_COST_SCHEDULE
  176.     double (*cost_schedule) ();
  177. #endif
  178. #if USER_REANNEAL_FUNCTION
  179.     double (*reanneal_function) ();
  180. #endif
  181. #if ASA_SAMPLE
  182.     LONG_INT n_accepted;
  183.     double bias_acceptance;
  184.     double *bias_generated;
  185.     double average_weights;
  186.     double limit_weights;
  187. #endif
  188. #if ASA_PARALLEL
  189.     int gener_mov_avr;
  190.     LONG_INT gener_block;
  191.     LONG_INT gener_block_max;
  192. #endif
  193.   }
  194. USER_DEFINES;
  195.  
  196.  /* system function prototypes */
  197.  
  198. #if HAVE_ANSI
  199.  
  200. /* This block gives trouble under some Ultrix */
  201. #if FALSE
  202. int fprintf (FILE * fp, char *string,...);
  203. void exit (int code);
  204. #endif
  205.  
  206. #if IO_PROTOTYPES
  207. int fprintf ();
  208. int fflush (FILE * fp);
  209. int fclose (FILE * fp);
  210. void exit ();
  211. #endif
  212.  
  213. double asa (double (*user_cost_function) (
  214.                double *, double *, double *, double *, double *,
  215.               ALLOC_INT *, int *, int *, int *, USER_DEFINES *),
  216.         double (*user_random_generator) (void),
  217.         double *parameter_initial_final,
  218.         double *parameter_minimum,
  219.         double *parameter_maximum,
  220.         double *tangents,
  221.         double *curvature,
  222.         ALLOC_INT * number_parameters,
  223.         int *parameter_type,
  224.         int *valid_state_generated_flag,
  225.         int *exit_status,
  226.         USER_DEFINES * OPTIONS);
  227.  
  228. #if TIME_CALC
  229. void print_time (char *message, FILE * ptr_out);
  230. #endif
  231.  
  232. #else /* HAVE_ANSI */
  233.  
  234. #if IO_PROTOTYPES
  235. int fprintf ();
  236. int fflush ();
  237. int fclose ();
  238. #endif
  239.  
  240. double asa ();
  241.  
  242. #if TIME_CALC
  243. void print_time ();
  244. #endif
  245.  
  246. #endif /* HAVE_ANSI */
  247.